package com.mvc.web.common.utils;

import java.util.concurrent.TimeUnit;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

public class CacheUtil {
	
	public static Cache<String, Object> cache = CacheBuilder.newBuilder()  
            .expireAfterWrite(240, TimeUnit.HOURS).maximumSize(10)  
            .build(); 
	
	public static void setcache(String key, Object value){
		cache.invalidate(key);
		cache.put(key, value);
	}
	
	public static Object getcache(String key){
		return cache.getIfPresent(key);
	}
	
	
	public static Cache<String, Object> cache_max = CacheBuilder.newBuilder()  
			.expireAfterWrite(100, TimeUnit.DAYS).maximumSize(10)  
			.build(); 
	
	public static void setcache_max(String key, Object value){
		cache_max.invalidate(key);
		cache_max.put(key, value);
	}
	
	public static Object getcache_max(String key){
		return cache_max.getIfPresent(key);
	}
	
	public static Cache<String, Object> cache_min = CacheBuilder.newBuilder()  
			.expireAfterWrite(2, TimeUnit.MINUTES).maximumSize(10)  
			.build(); 
	
	public static void setcache_min(String key, Object value){
		cache_min.invalidate(key);
		cache_min.put(key, value);
	}
	
	public static Object getcache_min(String key){
		return cache_min.getIfPresent(key);
	}
	
}